// @ts-ignore
/* eslint-disable */
import { request } from 'umi';

/** 修改网关配置 PUT /api/distribution/update/${id:/d/} */
export async function putApiDistributionUpdate_id_D(
  params: {
    // path
    /** 网关配置ID */
    id: string;
  },
  body: {
    /** 网关编号 */
    gatewayId?: string;
    /** 网关型号 */
    gatewayModel?: string;
    /** 名称：上传频率(秒)
说明：60, 300, 600, 1800, 3600 */
    uploadFrequency?: number;
    /** 名称：数据点上传开关
说明：值为假时，将数据点转存至调试表中 */
    pointUploadFlag?: boolean;
    /** 名称：报警规则上传开关
说明：值为假时，不上传报警规则 */
    alertUploadFlag?: boolean;
    /** 备注 */
    remark?: string;
  },
  options?: { [key: string]: any },
) {
  const { id: param0, ...queryParams } = params;
  return request<{
    id?: number;
    gatewayId?: string;
    gatewayModel?: string;
    uploadFrequency?: number;
    pointUploadFlag?: boolean;
    alertUploadFlag?: boolean;
    remark?: string;
    deployStatus?: 'WAITING' | 'SUCCESS' | 'FAIL';
    lastDeployTime?: string;
    online?: boolean;
  }>(`/api/distribution/update/${param0}`, {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json',
    },
    params: { ...queryParams },
    data: body,
    ...(options || {}),
  });
}

/** 分页获取网关配置 GET /api/distribution/page */
export async function getApiDistributionPage(
  params: {
    // query
    page: string;
    size: string;
    /** 网关编号 */
    key: string;
    /** 状态 */
    online: string;
  },
  options?: { [key: string]: any },
) {
  return request<{
    records?: {
      id?: number;
      gatewayId?: string;
      gatewayModel?: string;
      uploadFrequency?: number;
      pointUploadFlag?: boolean;
      alertUploadFlag?: boolean;
      remark?: string;
      deployStatus?: 'WAITING' | 'SUCCESS' | 'FAIL';
      lastDeployTime?: string;
      online?: boolean;
    }[];
    total?: number;
    size?: number;
    current?: number;
    pages?: number;
  }>('/api/distribution/page', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

/** 复制网关配置 POST /api/distribution/copy/${id:/d/} */
export async function postApiDistributionCopy_id_D(
  params: {
    // query
    gatewayId: string;
    // path
    id: string;
  },
  options?: { [key: string]: any },
) {
  const { id: param0, ...queryParams } = params;
  return request<{
    id?: number;
    gatewayId?: string;
    gatewayModel?: string;
    uploadFrequency?: number;
    pointUploadFlag?: boolean;
    alertUploadFlag?: boolean;
    online?: boolean;
    remark?: string;
    deployStatus?: 'WAITING' | 'SUCCESS' | 'FAIL';
    lastDeployTime?: string;
  }>(`/api/distribution/copy/${param0}`, {
    method: 'POST',
    params: {
      ...queryParams,
    },
    ...(options || {}),
  });
}

/** 新增网关配置 POST /api/distribution/create */
export async function postApiDistributionCreate(
  body: {
    /** 网关编号 */
    gatewayId?: string;
    /** 网关型号 */
    gatewayModel?: string;
    /** 名称：上传频率(秒)
说明：60, 300, 600, 1800, 3600 */
    uploadFrequency?: number;
    /** 名称：数据点上传开关
说明：值为假时，将数据点转存至调试表中 */
    pointUploadFlag?: boolean;
    /** 名称：报警规则上传开关
说明：值为假时，不上传报警规则 */
    alertUploadFlag?: boolean;
    /** 备注 */
    remark?: string;
  },
  options?: { [key: string]: any },
) {
  return request<{
    id?: number;
    gatewayId?: string;
    gatewayModel?: string;
    uploadFrequency?: number;
    pointUploadFlag?: boolean;
    alertUploadFlag?: boolean;
    remark?: string;
    deployStatus?: 'WAITING' | 'SUCCESS' | 'FAIL';
    lastDeployTime?: string;
    online?: boolean;
  }>('/api/distribution/create', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 获取网关配置 GET /api/distribution/${param1} */
export async function getApiDistribution_id_D(
  params: {
    // path
    /** 网关配置ID */
    id: string;
    'id:/d/': string;
  },
  options?: { [key: string]: any },
) {
  const { id: param0, 'id:/d/': param1, ...queryParams } = params;
  return request<{
    id?: number;
    gatewayId?: string;
    gatewayModel?: string;
    uploadFrequency?: number;
    pointUploadFlag?: boolean;
    alertUploadFlag?: boolean;
    remark?: string;
    deployStatus?: 'WAITING' | 'SUCCESS' | 'FAIL';
    lastDeployTime?: string;
    online?: boolean;
  }>(`/api/distribution/${param1}`, {
    method: 'GET',
    params: { ...queryParams },
    ...(options || {}),
  });
}

/** 配置下发 GET /api/distribution/deploy/${id:/d/} */
export async function getApiDistributionDeploy_id_D(
  params: {
    // path
    id: string;
  },
  options?: { [key: string]: any },
) {
  const { id: param0, ...queryParams } = params;
  return request<Record<string, any>>(`/api/distribution/deploy/${param0}`, {
    method: 'GET',
    params: { ...queryParams },
    ...(options || {}),
  });
}

/** 配置下发预览 GET /api/distribution/deploy/preview/${id:/d/} */
export async function getApiDistributionDeployPreview_id_D(
  params: {
    // path
    id: string;
  },
  options?: { [key: string]: any },
) {
  const { id: param0, ...queryParams } = params;
  return request<{
    distribution?: {
      gatewayId?: string;
      gatewayModel?: string;
      uploadFrequency?: number;
      pointUploadFlag?: boolean;
      alertUploadFlag?: boolean;
    };
    deviceList?: {
      device?: {
        driveType?:
          | 'MOD_BUS_RTU'
          | 'MOD_BUS_TCP'
          | 'MOD_BUS_RTU_OVER_TCP'
          | 'DLT645_1997'
          | 'DLT645_2007'
          | 'DATABASE'
          | 'HOST_LINK'
          | 'FINS_COM';
        serialport?: number;
        samplingInterval?: number;
        samplingTimeout?: number;
        samplingRetry?: number;
        baudrate?: number;
        dataBit?: number;
        stopBit?: number;
        parity?: 'NONE' | 'ODD' | 'EVEN' | 'MARK' | 'SPACE';
        ip?: string;
        port?: number;
        address?: string;
        leadByte?: number;
        slaveId?: number;
        groupLength?: number;
        crcOrder?: 'BIG_ORDER' | 'SMALL_ORDER';
      };
      modBusList?: {
        id?: number;
        driveType?:
          | 'MOD_BUS_RTU'
          | 'MOD_BUS_TCP'
          | 'MOD_BUS_RTU_OVER_TCP'
          | 'DLT645_1997'
          | 'DLT645_2007'
          | 'DATABASE'
          | 'HOST_LINK'
          | 'FINS_COM';
        acquisitionType?: 'MOMENTARY' | 'ACCUMULATION';
        valueCeiling?: number;
        valueFloor?: number;
        offset?: number;
        k?: number;
        b?: number;
        bitMode?: 'NONE' | 'BIT_MODE' | 'BYTE_MODE';
        bitNum?: number;
        byteNum?: 'LOWER' | 'HIGHER';
        dataId?: string;
        freq?: number;
        endian?: number;
        len?: number;
        fc?:
          | 'CIO'
          | 'HR'
          | 'AR'
          | 'LR'
          | 'DM'
          | 'TIMER_OR_COUNTER_PV'
          | 'TIMER_OR_COUNTER_STATUS'
          | 'EM';
        bitNot?: boolean;
        addr?: number;
        type?:
          | 'BOOL'
          | 'INTEGER_COMPLEMENT'
          | 'UNSIGNED_INTEGER'
          | 'FLOAT'
          | 'DOUBLE'
          | 'SIGNED_INTEGER';
      }[];
      dlt645List?: {
        id?: number;
        driveType?:
          | 'MOD_BUS_RTU'
          | 'MOD_BUS_TCP'
          | 'MOD_BUS_RTU_OVER_TCP'
          | 'DLT645_1997'
          | 'DLT645_2007'
          | 'DATABASE'
          | 'HOST_LINK'
          | 'FINS_COM';
        acquisitionType?: 'MOMENTARY' | 'ACCUMULATION';
        valueCeiling?: number;
        valueFloor?: number;
        offset?: number;
        k?: number;
        b?: number;
        bitMode?: 'NONE' | 'BIT_MODE' | 'BYTE_MODE';
        bitNum?: number;
        byteNum?: 'LOWER' | 'HIGHER';
        dataId?: string;
        freq?: number;
        endian?: number;
        len?: number;
        fc?:
          | 'CIO'
          | 'HR'
          | 'AR'
          | 'LR'
          | 'DM'
          | 'TIMER_OR_COUNTER_PV'
          | 'TIMER_OR_COUNTER_STATUS'
          | 'EM';
        bitNot?: boolean;
        addr?: number;
        type?:
          | 'BOOL'
          | 'INTEGER_COMPLEMENT'
          | 'UNSIGNED_INTEGER'
          | 'FLOAT'
          | 'DOUBLE'
          | 'SIGNED_INTEGER';
      }[];
    }[];
    virtualPointList?: {
      id?: number;
      formula?: string;
      valueCeiling?: number;
      valueFloor?: number;
    }[];
    alertRuleList?: {
      id?: number;
      formula?: string;
      keyPointId?: number;
      delay?: number;
      duration?: number;
      recordsAfter?: number;
      recordsBefore?: number;
      relatedIds?: number[];
    }[];
  }>(`/api/distribution/deploy/preview/${param0}`, {
    method: 'GET',
    params: { ...queryParams },
    ...(options || {}),
  });
}
